package com.itheima.prize.commons.db.service.impl;

import com.itheima.prize.commons.db.entity.CardProductDto;
import com.itheima.prize.commons.db.entity.CardUser;
import com.itheima.prize.commons.db.mapper.GameLoadMapper;
import com.itheima.prize.commons.db.service.GameLoadService;
import com.itheima.prize.commons.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class GameLoadServiceImpl implements GameLoadService {
    @Autowired
    private GameLoadMapper loadMapper;

    @Override
    public List<CardProductDto> getByGameId(int gameId) {
        return loadMapper.getByGameId(gameId);
    }

    @Override
    public Integer getGamesNumByUserId(int userid) {
        return loadMapper.getGamesNumByUserId(userid);
    }

    @Override
    public Integer getPrizesNumByUserId(int userid) {
        return loadMapper.getPrizesNumByUserId(userid);
    }

    /**
     * 查询用户id
     * @param request
     * @return
     */
    @Override
    public ApiResult getUserId(HttpServletRequest request) {
        HttpSession session = request.getSession();
        CardUser attribute =(CardUser) session.getAttribute("user");
        Integer id = attribute.getId();

        return null;
    }
}
